package org.ciallo.simplemusicplayer.data.model;

/**
 * @author Jukomu
 * @Description: 用于在列表中显示歌手信息的临时数据模型
 * @Package: org.ciallo.simplemusicplayer.data.model
 * @Project: SimpleMusicPlayer
 * @name: ArtistInfo
 * @Date: 2025/6/2-22:02
 * @Filename: ArtistInfo
 */
public class ArtistInfo {
    public final long artistId; // MediaStore.Audio.Artists._ID 或 Song.artistIdRoom
    public final String artistName;
    public final int songCount;
    public String artistPinyin; // 用于排序
    // 可以添加一个字段用于歌手的代表性专辑封面URI，从其歌曲中选取一个
    public String representativeAlbumArtUri;

    public ArtistInfo(long artistId, String artistName, int songCount, String artistPinyin, String representativeAlbumArtUri) {
        this.artistId = artistId;
        this.artistName = artistName;
        this.songCount = songCount;
        this.artistPinyin = artistPinyin;
        this.representativeAlbumArtUri = representativeAlbumArtUri;
    }

    // 重写 equals 和 hashCode 以便在 ListAdapter/DiffUtil 中正确比较
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        ArtistInfo that = (ArtistInfo) o;
        return artistId == that.artistId &&
                songCount == that.songCount &&
                java.util.Objects.equals(artistName, that.artistName) &&
                java.util.Objects.equals(artistPinyin, that.artistPinyin) &&
                java.util.Objects.equals(representativeAlbumArtUri, that.representativeAlbumArtUri);
    }

    @Override
    public int hashCode() {
        return java.util.Objects.hash(artistId, artistName, songCount, artistPinyin, representativeAlbumArtUri);
    }
}
